﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Project.Engine.Control;
using Project.Engine.Utilities;
using Project.Module.Model;
using Project.Module.DAO.BL;

namespace Project.Module.View
{
    public class ChiTietDonHangView : DocumentInfo
    {
        public CartModel detailOrder = null;
        public double total = 0;
        public List<GioHangModel> listGiohang = null;
        public CustomerModel customerOrder = null;
        private CustomerBL customerBl = new CustomerBL();
        private EventBL eventBl = new EventBL();
        //private FeedBackBL feedbackBl = new FeedBackBL();
        private CartBL cartBl = new CartBL();
        //private int donghangID = DefineUtil.donghangID;

        public ChiTietDonHangView(int nodeid, string nodealias)
        {
            Init(nodeid);
        }

        private void Init(int nodeid)
        {
            GetDetailOrder(nodeid);
            GetGioHang();                        
        }

        private void GetDetailOrder(int cartId)
        {
            this.detailOrder = cartBl.GetDetailOrder(cartId);
            if (this.detailOrder != null)
            {
                this.detailOrder.customerName = cartBl.GetCustomerName(cartId);
                this.detailOrder.addressCustomer = customerBl.GetAddress(this.detailOrder.CustomerID);

               //this.detailOrder.ImagePath = eventBl.GetImagePathById(this.detailProduct.ImageID);
               // this.detailOrder.CatagoryId = cartBl.ChitietInCMS(this.detailOrder.CatagoryId);
               // this.detailOrder.title = StringUtil.ShortContent(this.detailProduct.Description, 5);
            }
        }


        private void GetGioHang() {
            if (this.detailOrder != null) { 
                listGiohang = cartBl.GetListByCustomerId(this.detailOrder.CustomerID);
                if (listGiohang != null) {
                    foreach (var item in listGiohang) {
                        this.total += item.money;
                    }
                }
            }
        }
    }
}
